package com.ldn.basic.enumeration;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 李大牛家的牛 (scafel@163.com)
 * @createDate 2024/7/25 - 11:59
 * @description ...
 **/
@Schema(description = "轮播图跳转类型")
@Getter
public enum BannerJumpEnum {

    JUMP(1, "跳转"),
    BIND(2, "绑定"),
    UNKNOWN(-1, "未知"),
    ;

    private static final Map<Integer, BannerJumpEnum> codeToEnumMap = new HashMap<>();

    static {
        for (BannerJumpEnum type : BannerJumpEnum.values()) {
            codeToEnumMap.put(type.getCode(), type);
        }
    }

    private final int code;
    /**
     * 自定义描述
     **/
    private final String message;

    BannerJumpEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static BannerJumpEnum getType(int code) {
        BannerJumpEnum type = codeToEnumMap.get(code);
        if (type == null) {
            return BannerJumpEnum.UNKNOWN;
        }
        return type;
    }

}
